﻿/////////////////////////////////////////////////////////////
//
// Author Scott Herbert (www.scott-herbert.com)
//
// Version History 
// 1 (19-June-2011) Inital release on to Google code.
//
//
//


function getCookie(c_name)
{
var i,x,y,ARRcookies=document.cookie.split(";");
for (i=0;i<ARRcookies.length;i++)
  {
  x=ARRcookies[i].substr(0,ARRcookies[i].indexOf("="));
  y=ARRcookies[i].substr(ARRcookies[i].indexOf("=")+1);
  x=x.replace(/^\s+|\s+$/g,"");
  if (x==c_name)
    {
    return unescape(y);
    }
  }
}


function displayNotification()
{

// this sets the page background to semi-transparent black should work with all browsers
    var message = "<div id='cookiewarning' ><div class='popupouter'>";

// center vert
    message = message + "<div class='popupinner'>";

// this is the message displayed to the user.
message = message + "For at denne hjemmeside fungere korrekt , og vi kan forbedre hjemmesiden , er vi nødt til at gemme en lille fil (kaldet en cookie ) på din computer . <br/> De fleste hjemmesider gør dette, og siden den 25. maj 2011, skal man ved lov oplyse om dette, vi er nødt til at få din tilladelse først . <br/> Hvis du klikker accepter nedenfor vil vi gemme cookies.<br/>";
	
	
// Displays the I agree/disagree buttons.
// Feel free to change the address of the I disagree redirection to either a non-cookie site or a Google or the ICO web site 
message = message + "<INPUT TYPE='button' class='button' VALUE='Accepter' onClick='JavaScript:setCookie(\"jsCookieCheck\",null,365);' />";

	
// and this closes everything off.
message = message + "</div></div></div>";


document.writeln(message);


}

function setCookie(c_name,value,exdays)
{
var exdate=new Date();
exdate.setDate(exdate.getDate() + exdays);
var c_value=escape(value) + ((exdays==null) ? "" : "; expires="+exdate.toUTCString());
document.cookie=c_name + "=" + c_value;

// set cookiewarning to hidden.
var cw = document.getElementById("cookiewarning");
cw.innerHTML = "";
}

function checkCookie()
{

var cookieName="jsCookieCheck";
var cookieChk=getCookie(cookieName);
if (cookieChk!=null && cookieChk!="")
  {
  // the jsCookieCheck cookie exists so we can assume the person has read the notification
  // within the last year
  
  setCookie(cookieName,cookieChk,365);	// set the cookie to expire in a year.
  }
else 
  {
  // No cookie exists, so display the lightbox effect notification.
  displayNotification();	
  }
}

checkCookie();

